package homework.Day0322;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

public class Shuffle {
    public static void main(String[] args) {
        String[] sarr = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        String[] sarr1 = {"♠️","♥️","♦️","♣️"};

        ArrayList<String> playingCards = new ArrayList<>();
        for (String value : sarr1) {
            for (String s : sarr) {
                playingCards.add(value + s);
            }
        }
        playingCards.add("小王");
        playingCards.add("大王");
        System.out.println(playingCards.size());
        String[] cards = playingCards.toArray(new String[0]);
        for (int i = 0; i < cards.length; i++) {
            System.out.print(cards[i] + "  ");
            if ((i + 1) % 9 == 0){
                System.out.println();
            }
        }
        System.out.println();
        System.out.println();
        rearrangeCard(cards);

        System.out.println();
        System.out.println();
        rearrangeCard(cards);

    }

    public static void rearrangeCard(String[] sarr){
        Random ran = new Random();
        for (int i = 1; i < sarr.length; i++) {
            int in = ran.nextInt(i);
            String temp = sarr[in];
            sarr[in] = sarr[i];
            sarr[i] = temp;
        }
        for (int i = 0; i < sarr.length; i++) {
            System.out.print(sarr[i] + "  ");
            if ((i + 1) % 9 == 0){
                System.out.println();
            }
        }
    }
}
